// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//

#pragma once

#include <functional>
#include <string_view>

namespace nebula::csv {

    /// \brief Description of an invalid row
    struct InvalidRow {
        /// \brief Number of columns expected in the row
        int32_t expected_columns;
        /// \brief Actual number of columns found in the row
        int32_t actual_columns;
        /// \brief The physical row number if known or -1
        ///
        /// This number is one-based and also accounts for non-data rows (such as
        /// CSV header rows).
        int64_t number;
        /// \brief View of the entire row. Memory will be freed after callback returns
        const std::string_view text;
    };

    /// \brief turbo::Result returned by an InvalidRowHandler
    enum class InvalidRowResult {
        // Generate an error describing this row
        Error,
        // Skip over this row
        Skip
    };

    /// \brief callback for handling a row with an invalid number of columns while parsing
    /// \return result indicating if an error should be returned from the parser or the row is
    /// skipped
    using InvalidRowHandler = std::function<InvalidRowResult(const InvalidRow &)>;

}  // namespace nebula::csv
